#! /usr/bin/env python
# -*- coding:utf-8 -*-
# ====#====#====#====

import os, time
from configparser import ConfigParser

# 读取配置文件配置
# 定义读取配置文件类
class ReadConfig(object):
    # 定义初始化函数
    def __init__(self):
        # 获取配置文件路径
        self.file_path = os.path.dirname(os.path.dirname(__file__)) + r'/config'
        # 实例化ConfigParser
        self.conf = ConfigParser()
        # 读取配置文件
        self.conf.read(self.file_path, encoding='UTF-8')

    # 定义读取配置文件的对外调用类
    def read_conf(self, section, option = 'all'):
        if option == 'all':
            return self.conf.items(section)
        else:
            return self.conf.get(section, option)



if __name__ == '__main__':
    re = ReadConfig()
    print(re.read_conf('mysql', 'port'))
